home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Monitored frame - NETROM *)
- (* *)
- (* Copyright 1988, 1990, 1991 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- (*===========================================================================*)
- (* Monitor a channel *)
- (*===========================================================================*)
-
- PROCEDURE netrom_monitor(in_ptr : str_mixed_ptr;
- in_off : WORD;
- nodes_bcst : BOOLEAN);
-
- TYPE
-
- ax25_call = RECORD
- call_sign : ARRAY[1..6] OF BYTE;
- ssid : BYTE;
- END;
-
- ax25_call_ptr = ^ax25_call;
-
- netrom_header = RECORD
- call_1 : ax25_call;
- call_2 : ax25_call;
- t_to_l : BYTE;
- cindex : BYTE;
- cid : BYTE;
- data_1 : BYTE;
- data_2 : BYTE;
- opflag : BYTE;
- cdata : ARRAY[1..20] OF CHAR;
- END;
-
- netrom_header_ptr = ^netrom_header;
-
- CONST
- nr_choke = $80;
- nr_nak = $40;
- nr_more = $20;
- nr_reserve = $10;
- nr_opcode = $0F;
-
- VAR
- b : BOOLEAN;
- nr_code : BYTE;
- nr_code_str : STRING[8];
- nr_ptr : ^netrom_header;
- out_string : STRING;
- out_off : WORD;
- t : str_mixed;
-
- {$I BBAUXMNA.PAS} (* AX25 to call *)
- {$I BBAUXMNB.PAS} (* Nodes Broadcast *)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* If this is a nodes broadcast then handle that special *)
- (*-----------------------------------------------------------------------*)
-
- IF nodes_bcst THEN
- BEGIN;
- do_nodes_bcst;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Compute start of input data and output data *)
- (*-----------------------------------------------------------------------*)
-
- nr_ptr := @in_ptr^.long_data[in_off];
-
- out_off := in_off + 20;
-
- WITH nr_ptr^, in_ptr^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Decipher the to call and from call along with connect #s *)
- (*-------------------------------------------------------------------*)
-
- out_string := '(' + ax25_call_to_string(@call_1) + ' > ' +
- ax25_call_to_string(@call_2) + ', ' +
- b2x(t_to_l) + ', ' +
- b2x(cindex) + '/' +
- b2x(cid) + ' [';
-
- (*-------------------------------------------------------------------*)
- (* get the netrom opcode and decipher that *)
- (*-------------------------------------------------------------------*)
-
- nr_code := opflag AND nr_opcode;
-
- CASE nr_code OF
- 1 : nr_code_str := 'CR';
- 2 : nr_code_str := 'CA';
- 3 : nr_code_str := 'DR';
- 4 : nr_code_str := 'DA';
- 5 : nr_code_str := 'IF';
- 6 : nr_code_str := 'IA';
- ELSE
- nr_code_str := '??';
- END;
-
- (*-------------------------------------------------------------------*)
- (* Decipher flags *)
- (*-------------------------------------------------------------------*)
-
- i := opflag AND nr_choke;
- IF i <> 0 THEN
- nr_code_str := nr_code_str + '-C';
-
- i := opflag AND nr_nak;
- IF i <> 0 THEN
- nr_code_str := nr_code_str + '-N';
-
- i := opflag AND nr_more;
- IF i <> 0 THEN
- nr_code_str := nr_code_str + '-M';
-
- (*-------------------------------------------------------------------*)
- (* Build more output string *)
- (*-------------------------------------------------------------------*)
-
- out_string := out_string + nr_code_str;
-
- (*-------------------------------------------------------------------*)
- (* More special deciphering based on the netrom code *)
- (*-------------------------------------------------------------------*)
-
- b := TRUE;
-
- CASE nr_code OF
-
- 1: BEGIN; (* CR *)
-
- out_string := out_string + ']: ' +
- ax25_call_to_string(@cdata[2]) + '@' +
- ax25_call_to_string(@cdata[9]) + ' ' +
- w2c(ORD(cdata[1]));
- INC(out_off, 16);
- b := FALSE;
- END;
-
- 2: BEGIN; (* CA *)
- out_string := out_string + ']: ' + w2c(ORD(cdata[1]));
- INC(out_off, 2);
- b := FALSE;
- END;
-
- 5: BEGIN; (* IF *)
- out_string := out_string + ', ' + w2c(data_1) + ', ' +
- w2c(data_2);
- END;
-
- 6: BEGIN; (* IA *)
- out_string := out_string + ', ' + w2c(data_2);
- END;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* If b is true then end in a bracket else end in just paren *)
- (*-------------------------------------------------------------------*)
-
- IF b THEN
- BEGIN;
- IF long_length >= out_off THEN
- out_string := out_string + '])'
- ELSE
- out_string := out_string + ']):';
- END
- ELSE
- BEGIN;
- IF long_length >= out_off THEN
- out_string := out_string + ') -- '
- ELSE
- out_string := out_string + ')';
- END;
-
- (*-------------------------------------------------------------------*)
- (* If anything left on input line and we are not in a data frame, *)
- (* please display it in hex *)
- (*-------------------------------------------------------------------*)
-
- IF (long_length >= out_off) AND (nr_code <> 5) THEN
- BEGIN;
- i := 0;
- WHILE (long_length >= out_off) AND (i < 8) DO
- BEGIN;
- out_string := out_string + b2x(ORD(in_ptr^.str_data[out_off-1]));
- INC(out_off);
- INC(i);
- END;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Put CR on the line. Thats the end of the NETROM data *)
- (*-------------------------------------------------------------------*)
-
- out_string := out_string + cr;
-
- (*-------------------------------------------------------------------*)
- (* Now start building the l_string output *)
- (*-------------------------------------------------------------------*)
-
- IF in_off = 1 THEN
- WITH t DO
- BEGIN;
- long_length := 0;
- str_data := '';
- END
- ELSE
- t := l_substr(in_ptr, 1, in_off-1)^;
-
- (*-------------------------------------------------------------------*)
- (* Put the NETROM header info in the output buffer *)
- (*-------------------------------------------------------------------*)
-
- l_cat_str(@t, out_string);
-
- (*-------------------------------------------------------------------*)
- (* See if anything left for the output buffer from the input buffer *)
- (* Move as need be *)
- (*-------------------------------------------------------------------*)
-
- IF long_length > out_off THEN
- l_cat(@t, l_substr(in_ptr, out_off, 0));
-
- (*-------------------------------------------------------------------*)
- (* Put the output in the proper place *)
- (*-------------------------------------------------------------------*)
-
- in_ptr^ := t;
-
- END;
-
- END;
-
- PROCEDURE netrom_monitor_232;
-
- VAR
- i : WORD;
- j : WORD;
-
- BEGIN;
-
- i := l_pos(@in_1, cr);
-
- IF (i < 4) OR (i > 255) THEN
- EXIT;
-
- IF substr(in_1.str_data, i-3, 3) <> 'CF:' THEN
- EXIT;
-
- j := l_pos(@in_1, '>');
-
- IF (j < 1) OR (j > 249) THEN
- EXIT;
-
- netrom_monitor(@in_1, i + 1, substr(in_1.str_data, j + 1, 6) = 'NODES ');
-
- END;